package StringBuilderDemo;

import java.util.Scanner;

public class test2 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 获取金额
        System.out.println("请输入你的金额：");
        String money = sc.next();
        // 定义一个数组存储钱
        char[] money_arr = new char[7];
        // 将金额倒着输入数组
        for (int i = 0; i < money_arr.length; i++) {
            // 如果此单位为零则填入数组为零
            if (i < money_arr.length - money.length()){
                money_arr[i] = '0';
            }else{
                money_arr[i] = money.charAt(i - (money_arr.length - money.length()));
            }
        }
        // 将数字字符改为数字大写字符
        for (int i = 0; i < money_arr.length; i++) {
            switch (money_arr[i]){
                case '0' -> money_arr[i] = '零';
                case '1' -> money_arr[i] = '壹';
                case '2' -> money_arr[i] = '贰';
                case '3' -> money_arr[i] = '叁';
                case '4' -> money_arr[i] = '肆';
                case '5' -> money_arr[i] = '五';
                case '6' -> money_arr[i] = '陆';
                case '7' -> money_arr[i] = '柒';
                case '8' -> money_arr[i] = '扒';
                case '9' -> money_arr[i] = '玖';
            }
        }
        // 存储大写数字
        StringBuilder sb = new StringBuilder("零佰零仟零万零仟零佰零拾零元");
        for (int i = 0; i < money_arr.length; i++) {
            if (money_arr[i] != '0'){
                sb.setCharAt(i*2, money_arr[i]);
            }
        }
        System.out.println(sb);
    }
}
